package model

import (
	"gitee.com/zaiqiang231/lovesport-user-service/app/model/meta"
	"time"
)

type SysOperationRecord struct {
	meta.RecordModel
	Ip           string        `json:"ip" form:"ip" gorm:"column:ip;comment:请求ip"`                                   // 请求ip
	Method       string        `json:"method" form:"method" gorm:"column:method;comment:请求方法"`                       // 请求方法
	Path         string        `json:"path" form:"path" gorm:"column:path;comment:请求路径"`                             // 请求路径
	Status       int           `json:"status" form:"status" gorm:"column:status;comment:请求状态"`                       // 请求状态
	Latency      time.Duration `json:"latency" form:"latency" gorm:"column:latency;comment:延迟" swaggertype:"string"` // 延迟
	Agent        string        `json:"agent" form:"agent" gorm:"column:agent;comment:代理"`                            // 代理
	ErrorMessage string        `json:"error_message" form:"error_message" gorm:"column:error_message;comment:错误信息"`  // 错误信息
	Query        string        `json:"query" form:"query" gorm:"type:text;column:query;comment:请求query"`             // 请求query
	Body         string        `json:"body" form:"body" gorm:"type:text;column:body;comment:请求Body"`                 // 请求Body
	Resp         string        `json:"resp" form:"resp" gorm:"type:text;column:resp;comment:响应Body"`                 // 响应Body
	UserName     string        `json:"user_name" form:"user_name" gorm:"column:user_name;comment:用户名"`               // 用户id
	User         User          `json:"user" validate:"-" gorm:"foreignKey:Name;references:UserName"`
}

func (SysOperationRecord) TableName() string {
	return "sys_operation_records"
}
